#include "chatwidget.h"
#include "ui_chatwidget.h"

#include "clienthandler.h"

ChatWidget::ChatWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ChatWidget)
{
    ui->setupUi(this);

    QObject::connect(ui->lineEdit, &QLineEdit::returnPressed, [=](){
        QString text = ui->lineEdit->text();
        if(text.isEmpty() || username.isEmpty()) return;

        ClientHandlerChat::chat(text);
    });
}

ChatWidget::~ChatWidget()
{
    delete ui;
}

void ChatWidget::appendText(const QString& text)
{
    ui->textBrowser->append(text);
}
